#include<iostream>
#include<string>

class Student
{
    public:
        Student()  //无参构造函数：默认构造函数
        {
            std::cout<<"无参构造\n";
        }

        Student(int id, const char* name)   //构造函数允许重载
        {
            std::cout<<"有参构造\n";
            m_id=id;
            m_name=name;
        }

        //拷贝构造函数
        //由于拷贝构造函数会无限复制，所以拷贝构造函数中的形参要使用引用
        Student(const Student& s)
        {
            std::cout<<"拷贝构造函数\n";
            m_id=s.m_id;
            m_name=s.m_name;
        }

        //赋值运算符的重载
        void operator=(const Student &s)
        {
            std::cout<<"赋值运算符重载\n";
            m_id= s.m_id;
            m_name= s.m_name;
        }

        ~Student()
        {
            std::cout<<"析构函数"<<std::endl;
        }

        void Print()
        {
            std::cout<<m_id<<" "<<m_name<<std::endl;
        }

    private:
        int m_id;
        std::string m_name;
};

int main()
{
    Student s1(1,"zhangsan");
    // Student s2;
    // s2=s1;
    // s2.Print();
    return 0;
}